package com.monkeyk.sos.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Config {
	private static Logger log = Logger.getLogger(Config.class.getName());
	private static Properties properties = new Properties();
	private String fileName;
	Config(String fileName) {
		this.fileName=fileName;
		loadConfig();
	}
	public  String getConfigValue(String key){
		return properties.getProperty(key,null);
	}
	public  Properties getProperties(){
		return properties;
	}
	public void loadConfig() {
		InputStream is = Config.class.getClassLoader().getResourceAsStream(this.fileName);
		if(is != null){
			try {
				properties.load(is);
				log.log(Level.INFO, "加载classpath:"+fileName+"成功！");
			} catch (IOException e) {
				log.log(Level.WARNING, "加载classpath:"+fileName+"失败", e);
			}
		}
	}
}

